//
//  PopPresentController.swift
//  ZMWEIBO
//
//  Created by 庄猛 on 16/12/20.
//  Copyright © 2016年 BeiSheng. All rights reserved.
//

import UIKit
class PopPresentController: UIPresentationController {

    private lazy var bgButton:UIButton = {
     let but = UIButton(type: UIButtonType.custom)
        but.backgroundColor = UIColor(white: 0.5, alpha: 0.3)
//    but.backgroundColor = UIColor.clear
    but.addTarget(self, action: #selector(bgBtnDidClick), for: .touchUpInside)
        return but
    }()


    override init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?) {



        super.init(presentedViewController: presentedViewController, presenting: presentingViewController)
    }


    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
//        容器视图
//        let view = containerView
        let preView = presentedView
        preView?.frame = CGRect(x: 0, y: KScreenH - 330, width: KScreenW, height: 330)
        

    }

//视图即将弹出时添加蒙板
    override func presentationTransitionWillBegin(){
    super.presentationTransitionWillBegin()
       containerView?.addSubview(bgButton)
        bgButton.frame = containerView!.bounds;
    }


    @objc private func bgBtnDidClick(){

      presentedViewController.dismiss(animated: true, completion: nil)
        
     }


    deinit {
        QL1("消失了")
    }
}
